package com.adinnet.api.word.controller;


import com.adinnet.api.word.service.WordService;
import com.adinnet.core.JsonResult;
import com.adinnet.core.exception.BizException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 * 重点词汇表 前端控制器
 * </p>
 *
 * @author zYshuai
 * @since 2020-12-02
 */
@RestController
@RequestMapping("/api/word")
public class WordController {


    @Autowired
    private WordService wordService;

    /**
     * 查询词汇详情
     *
     * @return
     */
    @GetMapping("details")
    public JsonResult wordDetails(Integer id, String type, HttpServletRequest request, HttpServletResponse response) {
        try {
            if (null == id) {
                return JsonResult.error("id不能为空");
            }
            return wordService.wordDetails(id);

        } catch (BizException e) {
            return JsonResult.error(e.getMessage());
        } catch (Exception e) {
            return JsonResult.error("查询词汇详情失败!");
        }
    }

}
